-
-
Notifications
You must be signed in to change notification settings - Fork 489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace Python 3.9 by 3.12 in Conda workflow #36431
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In python 3.12, attribute errors add a suggestion at the end of the usual error message ("Did you mean ...?"). We add ... at the end of these doctest outputs to fix it. This commit has the bulk of the changes, obtained with: git grep -l "AttributeError:" src | xargs sed -ie \ 's/^ *\(AttributeError: .*\)\?has no attribute.*$/&.../'
In python 3.12, attribute errors add a suggestion at the end of the usual error message ("Did you mean ...?"). We add ... at the end of these doctest outputs to fix it. This commit has a few manual changes which didn't match the sed pattern in the previous commit.
The layout for python integers changed in python 3.12. We add a module `sage.cpython.pycore_long` which copies the new (internal) api of PyLong from python 3.12. We also implement fallback version of these functions suitable for python pre-3.12. Note the files implementing the `pycore_long` module (`pycore_long.pxd` and `pycore_long.h`) are shared with fpylll and cypari2.
In python 3.12, the `struct atexit_callback` was renamed to `struct atexit_py_callback`. The easiest workaround is to add `#define atexit_callback atexit_py_callback` in the right place when building using python 3.12 or newer.
Tracing has changed in python 3.12 in such a way that cython doesn't support it properly anymore. This one file sets `profile=true` for cython which won't work anymore (and it fails to build, at least with cython 0.29). We just disable that line. See also: cython/cython#5450
To use some (internal) declarations related to dict type, we have to include `<internal/pycore_dict.h>` which needs `#define Py_BUILD_CORE` to be loaded. This causes trouble when `Python.h` was included before defining `Py_BUILD_CORE`, due to a macro `_PyGC_FINALIZED`. We fix it by undefining said macro.
Some changes in ast, the old `node.n` and `node.s` are deprecated in favour of a common `node.value`. Making this change seems better than just ignoring the deprecation warning.
This adds some filterwarnings that trigger with python 3.12. - deprecation of `datetime.datetime.utcfromtimestamp()` this is triggered by python modules `dateutil` and `sphinx`. - `os.fork()` and `os.ptyfork()` are deprecated when running multi-threaded; I don't see an easy way out of this, so ignore it. - itertools won't support pickling in python 3.14; let's ignore this for now with the hope there's an alternative before 3.14.
Is deprecated, and it can be replaced just fine with `importlib.util.find_spec()`.
Since `importer.find_module(...)` was removed in 3.12. We just follow the suggestion from https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly Note that the last three added lines here could be replaced instead by spec.loader.load_module(module_name) which works; however this is deprecated so it's better to use the recommended way using `importlib.util.module_from_spec(...)` and `spec.loader.execute_module(...)`.
In python < 3.12 we have sage: a = delta_qexp(1000) sage: sum(a[n]/float(n)^14 for n in range(1,1000)) 0.9985830631627459 This changed in python 3.12 to sage: sum(a[n]/float(n)^14 for n in range(1,1000)) 0.9985830631627461 The latter is the correct one as can be seen using rationals: sage: float(sum(a[n]/n^14 for n in range(1,1000))) 0.9985830631627461 As a workaround, we do the sum in reverse (from small to large terms), which gives the correct result in any case: sage: sum(a[n]/float(n)^14 for n in reversed(range(1,1000))) 0.9985830631627461
In python 3.12 the printing of OrderedDict has been changed. As of Python 3.7, regular dicts are guaranteed to be ordered, so it's safe to replace OrderedDict by dict. Maybe convenient to replace other uses of OrderedDict, although this is out of scope of python 3.12 support.
Running sage: g = Polyhedron().face_generator() sage: g.__next__() A -1-dimensional face of a Polyhedron in ZZ^0 sage: g.__next__() is supposed to raise `StopIteration`. However in python 3.12 the second call to `__next__()` leads to a crash. This is caused by a `return -1` in `next_face_loop()` which is supposed to mean `raise StopIteration`. Using raise explicitly fixes the crash.
Documentation preview for this PR (built with commit e0cd6bb; changes) is ready! 🎉 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Enables conda workflow for Python 3.12, and removes older 3.9.
Currently blocked by
📝 Checklist
⌛ Dependencies